﻿@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@model LKVMLMADMIN.Models.LocalPasswordModel

@using (Html.BeginForm("Addorder", "Order", FormMethod.Post))
{
    <style>
        .alo{
            width:215px;
        }
        .alo1
        {
            width:400px;
        }
    </style>
    <h4 class="page-header">Mua sản phẩm</h4>
        <div class="col-md-6 col-md-offset-3">
            <div class="panel panel-default alo1">
                <div class="panel-heading panel-default">
                    <h3 class="panel-title">Mua đơn hàng</h3>
                </div>
                <div class="panel-body" style="margin-left:80px">
                    <form role="form">
                        <fieldset>
                            <div class="form-group">
                                <label>Mã thành viên</label>
                                <div></div>
                                @Html.DropDownList("User", new SelectList(@ViewBag.username, "UserId", "UserName", null), new { @class = "combobox" })

                            </div>
                            <div class="form-group">
                                <label>Gói sản phẩm</label>
                                @Html.DropDownList("Goi", new SelectList(@ViewBag.price, "value", "text", null), new { @class = "form-control alo", @Id = "cbGoi" })
                            </div>
                            <div class="form-group">
                                <label>Doanh số</label>
                                <ul class="errorMessages"></ul>
                                <input type="text" name="Amount" class="form-control alo" required="" id="txtAmount" value="0">
                            </div>
                            <div class="form-group">
                                <label>Mã đơn hàng</label>
                                <ul class="errorMessages"></ul>
                                <input type="text" name="ID_Order" class="form-control alo" required="">

                            </div>
                            @*<div class="form-group">
                                Kích hoạt &nbsp&nbsp  <input name="Check" type="checkbox" value="true" checked="true">
                            </div>*@
                            <button type="submit" class="btn_submit btn btn-default">Save</button>
                            <button type="reset" class="btn_submit btn btn-default">Cancel</button>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
}
<script>
    var createAllErrors = function () {
        var form = $(this),
            errorList = $("ul.errorMessages", form);

        var showAllErrorMessages = function () {
            errorList.empty();

            // Find all invalid fields within the form.
            var invalidFields = form.find(":invalid").each(function (index, node) {

                // Find the field's corresponding label
                var label = $("label[for=" + node.id + "] "),            
                    message = node.validationMessage || 'Invalid value.';

                errorList
                    .show()
                    .append("<li><span>" + label.html() + "</span> " + message + "</li>");
            });
        };

        // Support Safari
        form.on("submit", function (event) {
            if (this.checkValidity && !this.checkValidity()) {
                $(this).find(":invalid").first().focus();
                event.preventDefault();
            }
        });

        $("input[type=submit], button:not([type=button])", form)
            .on("click", showAllErrorMessages);

        $("input", form).on("keypress", function (event) {
            var type = $(this).attr("type");
            if (/date|email|month|number|search|tel|text|time|url|week/.test(type)
              && event.keyCode == 13) {
                showAllErrorMessages();
            }
        });
    };
    $('#cbGoi').change(function () {       
        var _valGoi = $('#cbGoi').find('option:selected').text();
        if (_valGoi != "Chọn gói")
        {
            $('#txtAmount').val(_valGoi.toString());
        }     
    });
    $("form").each(createAllErrors);
</script>